# -*- coding:utf-8 -*-

from django.db import models

class Category(models.Model):
    '总类别'
    name = models.CharField('类别名字', max_length=50, unique=True)
    desc = models.CharField('描述', max_length=200, null=True, blank=True)

    order = models.IntegerField('显示顺序', db_column='show_order', default=1,help_text='调整类别在菜单里显示的顺序')

    class Meta:
        ordering = ['order']
        verbose_name = '类别'
        verbose_name_plural = verbose_name


    def __unicode__(self):
        return self.name

class Department(models.Model):
    '部门'
    name = models.CharField('部门名字', max_length=50, unique=True)
    desc = models.CharField('描述', max_length=200, null=True, blank=True)

    order = models.IntegerField('显示顺序', db_column='show_order', default=1,help_text='调整部门在类别下显示的顺序')
    category = models.ManyToManyField(Category, verbose_name='所在类别')

    class Meta:
        ordering = ['order']
        verbose_name = '部门'
        verbose_name_plural = verbose_name

    def __unicode__(self):
        return self.name

class Employee(models.Model):
    '员工'
        
    name = models.CharField('员工名字', max_length=50)
    post = models.CharField('岗位名称', max_length=50)
    inner = models.IntegerField('内线', db_column='inner_tel', null=True, blank=True)
    outer = models.IntegerField('外线', db_column='outer_tel', null=True, blank=True)
    short_tel = models.IntegerField('短号', null=True, blank=True)
    mobile = models.IntegerField('手机', null=True, blank=True)
    telephone = models.IntegerField('住宅电话', null=True, blank=True)
    remark = models.CharField('备注', max_length=50, null=True, blank=True)

    order = models.IntegerField('显示顺序', db_column='show_order', default=1,help_text='调整员工在部门下显示的顺序')
    department = models.ManyToManyField(Department, verbose_name='所在部门')
    
    class Meta:
        ordering = ['order']
        verbose_name = '员工'
        verbose_name_plural = verbose_name

    def __unicode__(self):
        return self.name + ':' + self.post

